namespace server.Models;
public class BooksResponse
{
    public int TotalCount { get; set; }
    public int PageOffset { get; set; }
    public int PageSize { get; set; }
    public IEnumerable<Book> Books { get; set; } = null!;
}

public class LoginResponse
{
    public int ID { get; set; }
    public string NickName { get; set; } = null!;
    public string Token { get; set; }=null!;
    public string Role { get; set; } = null!;
}

public class ImportResponse
{
    public int AcceptCount { get; set; }
    public int RepeatCount { get; set; }
    public int ImportCount { get; set; }
    public string Message { get; set; } = null!;
}

public class UserResponse
{
    public int ID { get; set; }
    public string Name { get; set; }
    public string NickName { get; set; }
    public string Role { get; set; }

    public UserResponse(User u, string role)
    {
        ID = u.ID;
        Name = u.Name;
        NickName = u.NickName;
        Role = role;
    }
}

public class BorrowRecordResponse{
    public int ID { get; set; }
    public string BookName { get; set; }=null!;
    public string BorrowDate { get; set; }
    public string? ReturnDate { get; set; }

    public BorrowRecordResponse(BorrowRecord br)
    {
        ID=br.Id;
        BookName=br.Book.BookName;
        BorrowDate=DateOnly.FromDateTime(br.BorrowDate).ToString();
        ReturnDate=br.ReturnDate.HasValue?DateOnly.FromDateTime(br.ReturnDate.Value).ToString():null;
    }
}

public class UserBorrowRecordResponse:BorrowRecordResponse{
    public string UserName { get; set; }=null!;
    public UserBorrowRecordResponse(BorrowRecord br):base(br)
    {
        UserName=br.User.Name;
    }
}